package org.achartengine.internal;

import android.graphics.RectF;
import android.view.MotionEvent;
import org.achartengine.internal.chart.k;
import org.achartengine.internal.renderer.XYMultipleSeriesRenderer;

/* loaded from: classes2.dex */
public class e implements ITouchHandler {
    private XYMultipleSeriesRenderer a;
    private float b;
    private float c;
    private RectF d;
    private org.achartengine.internal.a.c e;
    private GraphicalView f;

    public e(GraphicalView graphicalView, org.achartengine.internal.chart.a aVar) {
        this.d = new RectF();
        this.f = graphicalView;
        this.d = graphicalView.e();
        k kVar = (k) aVar;
        XYMultipleSeriesRenderer e = kVar.e();
        this.a = e;
        if (e.S() || this.a.T()) {
            this.e = new org.achartengine.internal.a.c(kVar);
        }
    }

    @Override // org.achartengine.internal.ITouchHandler
    public void handleTouch(MotionEvent motionEvent) {
        int action = motionEvent.getAction();
        if (this.a != null && action == 2) {
            if (this.b >= 0.0f || this.c >= 0.0f) {
                float x = motionEvent.getX();
                float y = motionEvent.getY();
                if (this.a.S() || this.a.T()) {
                    this.e.a(this.b, this.c, x, y);
                }
                this.b = x;
                this.c = y;
                this.f.f();
            }
        } else if (action != 0) {
            if (action == 1) {
                this.b = 0.0f;
                this.c = 0.0f;
            }
        } else {
            this.b = motionEvent.getX();
            this.c = motionEvent.getY();
            XYMultipleSeriesRenderer xYMultipleSeriesRenderer = this.a;
            if (xYMultipleSeriesRenderer != null) {
                if ((xYMultipleSeriesRenderer.U() || this.a.V()) && this.d.contains(this.b, this.c)) {
                    if (this.b < this.d.left + (this.d.width() / 3.0f)) {
                        this.f.b();
                    } else if (this.b < this.d.left + ((this.d.width() * 2.0f) / 3.0f)) {
                        this.f.c();
                    } else {
                        this.f.d();
                    }
                }
            }
        }
    }
}
